#include <CGamer.h>
#include <Perlin.h>


void createWhitenoise() {
  CGraph g, g2;
  int N = 1000;
  g.Initialize(N);
  g2.Initialize(N);
  for (int i=0;i<N;i++) {
    g.Val[i] = (rand()%1000)/1000.0 - 0.5;
    g.Index[i] = i;

    g2.Val[i] = g.Val[i];
    g2.Index[i] = i;
    
  }
  g.scaleX(1);
  g.Normalize();
  g.SaveText("whitenoise1.txt");
  g.fitSpline(g2, 1000);
  g2.Normalize();
  g2.SaveText("whitenoise2.txt");
  g.fitSpline(g2, 15);

  g2.Normalize();
  g2.SaveText("whitenoise3.txt");


}

CGraph* createPerlin(string s, double scale) {
  CGraph* g = new CGraph();
  int N = 1000;

  Perlin* p = new Perlin(1, 1, 1, 0);

  g->Initialize(N);
  for (int i=0;i<N;i++) {
    g->Val[i] = p->Get((i/(double)N)*scale, 0);
    g->Index[i] = i;
  }
  g->scaleX(1);
  g->Normalize();
  g->SaveText(s);

  return g;
}


int main(int argc, char *argv[]) {

  /*  CGraph sum;
  sum.Initialize(1000);

  sum.Add(*createPerlin("perlin1.txt", 4),1);
  sum.Add(*createPerlin("perlin2.txt", 15),0.5);
  sum.Add(*createPerlin("perlin3.txt", 50),0.1);
 
  sum.SaveText("perlin4.txt");
  */

  CGamer gamer;
  gamer.Initialize(argc, argv);
  //  gamer.createPerlinNoiseImages(1);
  return 0;
}
